<?php
class classMenu{
	public function getMenu($csMenuType, $csMenuDestination){
		//class for URL processing
		$_URL = new classURL();
	
		$result = '<dl id="menu">';
		
		$iNo = 0;	//top categorie's counter
		$TMnu_Source=mysql_query("SELECT * FROM top_category ORDER BY TC_Order, TC_Caption");
		while($sql_array_TMnu = mysql_fetch_object($TMnu_Source))
		{
			$iNo++;
			if($sql_array_TMnu->TC_Have_SC!=1){	//ak neexistuje podmenu
				//zaistenie ID podkategorie be nadpisu
				$SMnu_Source=mysql_query("SELECT * FROM sub_category WHERE TC_ID=".$sql_array_TMnu->ID);
				$sql_array_SMnu = mysql_fetch_object($SMnu_Source);
				//vygenerovanie topkategorie s odkazom:
				$result .= '
					<dt onmouseover="javascript:montre(\'smenu'.$iNo.'\');montreTopMenu();">
						<a href="'.$_URL->SetURL('','name'._URL_VAL_DELIMITER_.$sql_array_SMnu->ID._URL_VAL_DELIMITER_.'0'._URL_VAL_DELIMITER_.'0', '').'"
						>
							'.$sql_array_TMnu->TC_Caption.'
						</a>
					</dt>
				';
			}
			else{	//ak existuje podmenu
				//vygenerovanie topkategorie bez odkazu:
				$result .= '
					<dt onmouseover="javascript:montre(\'smenu'.$iNo.'\');montreTopMenu();">
						<a href="'._URL_INACTIVE_ADDR_.'">'.$sql_array_TMnu->TC_Caption.'</a>
					</dt>
				';
				//vygenerovanie subkategorii:
				$result .= '
					<dd id="smenu'.$iNo.'" onmouseover="javascript:montre(\'smenu'.$iNo.'\');montreTopMenu();" onmouseout="javascript:montre();"> 
    					<ul>
				';
				
				$SMnu_Source=mysql_query("SELECT * FROM sub_category WHERE TC_ID=".$sql_array_TMnu->ID." ORDER BY SC_Order, SC_Caption");
				while($sql_array_SMnu = mysql_fetch_object($SMnu_Source))
				{
					$result .= '
						<li>
							<a href="'.$_URL->SetURL('','name'._URL_VAL_DELIMITER_.$sql_array_SMnu->ID._URL_VAL_DELIMITER_.'0'._URL_VAL_DELIMITER_.'0', '').'"
							>
								'.$sql_array_SMnu->SC_Caption.'
							</a>
						</li>
					';
				}
				$result .= '
						</ul>
					</dd>
				';
			}
		}
		
		$result .= '
			</dl>
			<input type="hidden" name="Selected_Product_Category" id="Selected_Product_Category" value="5">		
		';
				
		return $result;
	}
}
?>